<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/5
 * Time: 16:52
 */

namespace Admin\Model;
use Think\Model;

/**
 * Class AuthRuleModel
 * @package Admin\Model
 * 权限规则
 */
class AuthRuleModel extends Model
{
    protected $pk='id';
    protected $tableName='auth_rule';
    protected $_validate=[
        ['name','require','规则不能为空'],
        ['title','require','规则标识不能为空']
    ];
   /**
    * 添加权限规则
    */
    public function addrules($data){
//        dd($data);die;
        if($this->create($data)){
            if($data['id']){
                $this->save($data);
            }
            $this->add($data);
           return ['valid'=>1,'msg'=>'添加成功'];
        }else{
            return ['valid'=>0,'msg'=>$this->getError()];
        }
    }
}